package cn.sinata.wanglin.neighbor.activity;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;

import com.hyphenate.chat.EMConversation;
import com.hyphenate.easeui.EaseConstant;
import com.hyphenate.easeui.ui.EaseConversationListFragment;
import com.xilada.xldutils.activitys.TitleActivity;
import com.xilada.xldutils.utils.ActivityUtil;

import butterknife.BindView;
import cn.sinata.wanglin.R;
import cn.sinata.wanglin.neighbor.fragment.ContactsFragment;
import cn.sinata.wanglin.neighbor.fragment.FindUserByIdFragment;
import cn.sinata.wanglin.neighbor.fragment.FindUserByVillageFragment;
import cn.sinata.wanglin.neighbor.fragment.NeighborFragment;
import cn.sinata.wanglin.neighbor.fragment.NeighborNearbyFragment;

public class FindFriendActivity extends TitleActivity {

    @BindView(R.id.mTabLayout)
    TabLayout mTabLayout;
    @BindView(R.id.mViewPager)
    ViewPager mViewPager;

    @Override
    protected int setContentId() {
        return R.layout.activity_find_friend;
    }

    @Override
    protected void initView() {
        super.initView();
        setTitle("添加朋友");

        mTabLayout.setTabTextColors(ContextCompat.getColor(this,R.color.gray_color_9ab)
                ,ContextCompat.getColor(this,R.color.yellow_color_81d));
        mTabLayout.setTabMode(TabLayout.MODE_FIXED);
        mTabLayout.setSelectedTabIndicatorColor(ContextCompat.getColor(this,R.color.yellow_color_81d));
        mViewPager.setAdapter(new FragmentAdapter(getSupportFragmentManager()));
        mTabLayout.setupWithViewPager(mViewPager);
    }

    private class FragmentAdapter extends FragmentStatePagerAdapter {

        public FragmentAdapter(FragmentManager fm) {
            super(fm);
        }

        String[] titles = {"通过小区","通过号码"};

        @Override
        public Fragment getItem(int position) {
            if (position == 0) {
                return new FindUserByVillageFragment();
            } else {
                return new FindUserByIdFragment();
            }
        }

        @Override
        public int getCount() {
            return titles.length;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return titles[position];
        }
    }
}
